using System;
using Microsoft.Xna.Framework;

namespace MicroStar
{
    /// <summary>
    /// Force to push particles randomly in all directions after emission
    /// </summary>
    public class Randomize : Force
    {
        private readonly Random random;

        ///<summary>
        /// Constructor
        ///</summary>
        public Randomize()
        {
            random = new Random();
        }

        internal override void Initialize(ref Particle particle)
        {
            Vector2 velocity = new Vector2((float)random.NextDouble() * ParticleSpeed, 0);
            float angle = MathHelper.ToRadians(random.Next(360));
            particle.Velocity = Vector2.Transform(velocity, Matrix.CreateRotationZ(angle));
        }
    }
}
